package com.xiaoze.question.factory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;

@Service
@SuppressWarnings("rawtypes")
public class SceTacFactory {

	@Autowired
	Map<String, SceTacStrategy> sts = new ConcurrentHashMap<>();
	
	public SceTacStrategy getStrategy(String component) {
		SceTacStrategy strategy = sts.get(component);
		Optional.ofNullable(strategy).orElseThrow(() -> new RuntimeException("生活缴费工厂类创建实例出错,没有该实例：" + component));
		return strategy;
	}
}